package com.csmht.tododemo.until;

import com.csmht.tododemo.pojo.entity.Role;
import com.csmht.tododemo.pojo.enumeration.RoleEnum;

public class BaseUnit {

    public static ThreadLocal<Role> threadLocal = new ThreadLocal<>();

    public static void setCurrentId(Long id) {
        Role role =Role.builder().build();
        role.setId(id);
        role.setRole(RoleEnum.USER);
        threadLocal.set(role);
    }

    public static void setCurrentId(Role role) {
        threadLocal.set(role);
    }

    public static Long getCurrentId() {
        return threadLocal.get().getId();
    }

    public static Role getCurrentRole() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }



}
